package com.lightsaber.trade.cloth.entity.category;

import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import com.lightsaber.trade.core.entity.BaseEntity;
import com.lightsaber.trade.cloth.entity.archive.ArchivedImage;
import com.lightsaber.trade.cloth.entity.planning.Level1Planning;
import com.lightsaber.trade.cloth.entity.planning.Planning;
import com.lightsaber.trade.cloth.entity.planning.PlanningStatus;

@Entity
@Table(name = "MHPP_CATEGORY")
public class Category extends BaseEntity {

    private static final long serialVersionUID = -5545643047173232486L;

    @Column(name = "IS_ARCHIVED_IMAGE", length = 10)
    private Boolean isArchivedImage;

    @Column(name = "PLAN_YEAR", nullable = false)
    private Integer planYear;

    @Column(name = "BRANCH_NAME", nullable = true, length = 100)
    private String branchName;

    @Column(name = "PLANNING_EXERCISE_NAME", nullable = false, length = 100)
    private String planningExerciseName;

    @Column(name = "LEVEL_1_START", nullable = false)
    private Integer level1Start;

    @Column(name = "LEVEL_1_END", nullable = false)
    private Integer level1End;

    @Column(name = "LEVEL_2_START", nullable = false)
    private Integer level2Start;

    @Column(name = "LEVEL_2_END", nullable = false)
    private Integer level2End;

    @Column(name = "LEVEL_3_START", nullable = false)
    private Integer level3Start;

    @Column(name = "LEVEL_3_END", nullable = false)
    private Integer level3End;

    @Column(name = "REMARKS", nullable = true, length = 4000)
    private String remarks;

    @Enumerated(EnumType.STRING)
    @Column(name = "ENDORSEMENT_STATUS", nullable = true)
    private PlanningStatus endorsementStatus;

    @Column(name = "ENDORSEMENT_TIME", nullable = true)
    private Date endorsementTime;

    @OneToOne(mappedBy = "category", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
    private CategoryNode root;

    @OneToOne(mappedBy = "category", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
    private Level1Planning level1Planning;

    @OneToMany(mappedBy = "category", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
    private List<Planning> planningList;

    @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
    @JoinColumn(name = "OWNER_NODE_ID", nullable = true)
    private CategoryNode ownerNode;

    // added by dj
    @OneToMany(mappedBy = "category", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
    private List<ArchivedImage> archivedImageList;

    public List<ArchivedImage> getArchivedImageList() {
        return archivedImageList;
    }

    public void setArchivedImageList(final List<ArchivedImage> archivedImageList) {
        this.archivedImageList = archivedImageList;
    }

    public Integer getPlanYear() {
        return planYear;
    }

    public void setPlanYear(final Integer planYear) {
        this.planYear = planYear;
    }

    public String getRemarks() {
        return remarks;
    }

    public List<Planning> getPlanningList() {
        return planningList;
    }

    public void setPlanningList(final List<Planning> planningList) {
        this.planningList = planningList;
    }

    public void setRemarks(final String remarks) {
        this.remarks = remarks;
    }

    public CategoryNode getRoot() {
        return root;
    }

    public void setRoot(final CategoryNode root) {
        this.root = root;
    }

    public CategoryNode getOwnerNode() {
        return ownerNode;
    }

    public void setOwnerNode(final CategoryNode ownerNode) {
        this.ownerNode = ownerNode;
    }

    public String getBranchName() {
        return branchName;
    }

    public void setBranchName(final String branchName) {
        this.branchName = branchName;
    }

    public String getPlanningExerciseName() {
        return planningExerciseName;
    }

    public void setPlanningExerciseName(final String planningExerciseName) {
        this.planningExerciseName = planningExerciseName;
    }

    public Integer getLevel1Start() {
        return level1Start;
    }

    public void setLevel1Start(final Integer level1Start) {
        this.level1Start = level1Start;
    }

    public Integer getLevel1End() {
        return level1End;
    }

    public Boolean getIsArchivedImage() {
        return isArchivedImage;
    }

    public void setIsArchivedImage(final Boolean isArchivedImage) {
        this.isArchivedImage = isArchivedImage;
    }

    public void setLevel1End(final Integer level1End) {
        this.level1End = level1End;
    }

    public Integer getLevel2Start() {
        return level2Start;
    }

    public void setLevel2Start(final Integer level2Start) {
        this.level2Start = level2Start;
    }

    public Integer getLevel2End() {
        return level2End;
    }

    public void setLevel2End(final Integer level2End) {
        this.level2End = level2End;
    }

    public Integer getLevel3Start() {
        return level3Start;
    }

    public void setLevel3Start(final Integer level3Start) {
        this.level3Start = level3Start;
    }

    public Integer getLevel3End() {
        return level3End;
    }

    public void setLevel3End(final Integer level3End) {
        this.level3End = level3End;
    }

    public PlanningStatus getEndorsementStatus() {
        return endorsementStatus;
    }

    public void setEndorsementStatus(final PlanningStatus endorsementStatus) {
        this.endorsementStatus = endorsementStatus;
    }

    public Date getEndorsementTime() {
        return endorsementTime;
    }

    public void setEndorsementTime(final Date endorsementTime) {
        this.endorsementTime = endorsementTime;
    }

    public Level1Planning getLevel1Planning() {
        return level1Planning;
    }

    public void setLevel1Planning(final Level1Planning level1Planning) {
        this.level1Planning = level1Planning;
    }

}
